package com.dk.controller;

import com.dk.pojo.User;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

//流式操作
public class MyTest03 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("张三丰");
        list.add("张无忌");
        list.add("张琪超");
        list.add("宋美龄");
        list.add("宋志乾");
        Function<String, User> f=name->new User(name);
        List<User> ll = list.stream().filter(a -> a.startsWith("宋") && a.length() == 3).map(f).collect(Collectors.toList());
        ll.stream().forEach(System.out::println);
//        list.stream().filter(a->a.startsWith("张")&&a.length()==3).forEach(System.out::println);
//        List<String> newll=list.stream().filter(a->a.startsWith("张")&&a.length()==3).collect(Collectors.toList());
//        newll.stream().forEach(System.out::println);

//        String[] ss= {"a","b","c","d","r","j","l","s"};
//        Stream.of(ss).skip(3).limit(3).forEach(System.out::println);

        String[] arr={"abc","bcd","sds"};
        Stream<String> s=Stream.of(arr);
    }
}
